package eventplanner.rest;

import eventplanner.ejb.ServiceFacade;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/calendar")
public class CalendarRestService {

	@Inject
	private ServiceFacade serviceFacade;

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Response getCalendars() {
		return Response.ok(serviceFacade.getCalendars()).build();
	}

	@GET
	@Path("/{calendarId}")
	@Produces(MediaType.APPLICATION_JSON)
	public Response getCalendar(@PathParam("calendarId") long calendarId) {
		return Response.ok(serviceFacade.getCalendar(calendarId)).build();
	}

	@GET
	@Path("/{calendarId}/event/{eventId}")
	@Produces(MediaType.APPLICATION_JSON)
	public Response getEvent(@PathParam("eventId") long eventId) {
		return Response.ok(serviceFacade.getEvent(eventId)).build();
	}
}
